{layout name="layout/food" /}
<link rel="stylesheet" href="/assets/plugins/layui/css/layui.css"/>
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">编辑门店</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 门店名称 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[shop_name]"
                                           placeholder="请输入门店名称" value="{$model['shop_name']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label"> 门店logo </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        <div class="am-form-file">
                                            <button type="button"
                                                    class="upload-file am-btn am-btn-secondary am-radius">
                                                <i class="am-icon-cloud-upload"></i> 选择图片
                                            </button>
                                            <div class="uploader-list am-cf">
												<div class="file-item">
													<img src="{$model['logo']}">
													<input type="hidden" name="data[logo]" value="{$model['logo']}">
													<i class="iconfont iconshanchu file-item-delete"></i>
												</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
							<div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label"> 门头照片 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        <div class="am-form-file">
                                            <button type="button" class="upload-file-front am-btn am-btn-xs am-btn-secondary am-radius">
                                                <i class="am-icon-cloud-upload"></i> 选择图片
                                            </button>
                                            <div class="uploader-list am-cf">
												<div class="file-item">
													<img src="{$model['front']}">
													<input type="hidden" name="data[front]" value="{$model['front']}">
													<i class="iconfont iconshanchu file-item-delete"></i>
												</div>
                                            </div>
                                        </div>
										<div class="help-block am-margin-top-sm">
                                            <small>尺寸750x300像素以上，大小2M以下</small>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group am-padding-top">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 联系人 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[linkman]"
                                           placeholder="请输入门店联系人" value="{$model['linkman']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 联系电话 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[phone]"
                                           placeholder="请输入门店联系电话" value="{$model['phone']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 营业时间 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" id="shop_hours" class="tpl-form-input" name="data[shop_hours]" 
                                           placeholder="请选择营业时间" value="{$model['shop_hours']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 详细地址 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[address]"
                                           placeholder="请输入详细地址" value="{$model['address']}" required>
									<small>不用填写省、市、区/县</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 门店坐标 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-block">
                                        <input type="text" style="background: none !important;" id="coordinate"
                                               class="tpl-form-input" name="data[coordinate]" placeholder="请选择门店坐标" 
											   value="{$model['coordinate']}" readonly="" required>
                                    </div>
                                    <div class="am-block am-padding-top-xs">
                                        <iframe id="map" src="/store/food.shop/getpoint" width="915" height="610"></iframe>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group am-padding-top">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label"> 门店简介 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <textarea class="am-field-valid" rows="5" placeholder="请输入门店简介"
                                              name="data[summary]">{$model['summary']}</textarea>
                                </div>
                            </div>
							<div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">堂食模式 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[tang_mode]" value="1" data-am-ucheck 
										{$model['tang_mode'] == 1?'checked':''}>
                                        选桌点餐
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[tang_mode]" value="2" data-am-ucheck 
										{$model['tang_mode'] == 2?'checked':''}>
                                        排号点餐
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 自动接单 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[is_order]" value="0" data-am-ucheck 
                                        {$model['is_order']['value'] == 0?'checked':''}>
                                        关闭
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[is_order]" value="1" data-am-ucheck 
                                        {$model['is_order']['value'] == 1?'checked':''}>
                                        开启
                                    </label>
                                </div>
                            </div>
							<div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 自动配送 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input v-model="checked" type="radio" name="data[is_delivery]" value="0" 
											{$model['is_delivery']['value'] == 0?'checked':''} data-am-ucheck>
                                        关闭
                                    </label>
                                    <label class="am-radio-inline">
                                        <input v-model="checked" type="radio" name="data[is_delivery]" value="1" 
										{$model['is_delivery']['value'] == 1?'checked':''} data-am-ucheck>
                                        开启
                                    </label>
									<div class="help-block">
                                        <small>用户下单后是否自动接受订单</small>
                                    </div>
                                </div>
                            </div>
							<div v-show="checked == 1" class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 配送公司 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[delivery]" value="self" 
										{$model['delivery'] == 'self'?'checked':''} data-am-ucheck>
                                        商家自配
                                    </label>
                                    {foreach $company as $item}
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[delivery]" value="{$item['name']}" 
                                        {$model['delivery'] == $item['name'] ? 'checked' : ''} data-am-ucheck>
                                        {$item['title']}
                                    </label>
                                    {/foreach}
                                    <div class="help-block">
                                        <small>请咨询服务商后选择设置</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 骑手抢单 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[is_grab]" value="0" data-am-ucheck {$model['is_grab']['value'] == 0?'checked':''}>
                                        关闭
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[is_grab]" value="1" data-am-ucheck {$model['is_grab']['value'] == 1?'checked':''}>
                                        开启
                                    </label>
                                    <div class="help-block">
                                        <small>商家自配有效，开启后需要骑手接单。关闭后配送员为店长</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">顺丰门店ID </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[sf_shop_id]"
                                           value="{$model['sf_shop_id']}">
                                    <small>使用顺丰配送必须配置该项</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">达达门店ID </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[dada_shop_id]"
                                           value="{$model['dada_shop_id']}">
                                    <small>使用达达配送必须配置该项</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">码科门店ID </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[make_shop_id]"
                                           value="{$model['make_shop_id']}">
                                    <small>使用码科配送必须配置该项</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 门店状态 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[status]" value="1" data-am-ucheck
                                               {$model['status']['status'] == 1?'checked':''}>
                                        营业中
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[status]" value="0" data-am-ucheck 
                                        {$model['status']['status'] == 0?'checked':''}>
                                        歇业中
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">显示排序 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="number" class="tpl-form-input" name="data[sort]"
                                           value="{$model['sort']}" required>
                                    <small>数字越小越靠前</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交
                                    </button>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 图片文件列表模板 -->
{include file="../addons/upload/view/template/tpl_file_item_url.html" /}
<!-- 文件库弹窗 -->
{include file="../addons/upload/view/template/file_library.html" /}
<script src="/assets/plugins/layui/layui.js" charset="utf-8"></script>
<script src="/assets/plugins/vue/vue.min.js"></script>
<script>
    layui.use('laydate', function(){
      var laydate = layui.laydate;
      //时间范围
      laydate.render({
        elem: '#shop_hours'
        ,format: 'HH:mm'
        ,type: 'time'
        ,range: true
      });
    });
    /**
     * 设置坐标
     */
    function setCoordinate(value) {
        var $coordinate = $('#coordinate');
        $coordinate.val(value);
        // 触发验证
        $coordinate.trigger('change');
    }
	
    $(function () {
		new Vue({
		  el: '#my-form',
		  data: {
			checked:"{$model['is_delivery']['value']}"
		  }
		});
        // 选择图片
        $('.upload-file').selectImages({
            name: 'data[logo]'
        });
		// 选择图片
        $('.upload-file-front').selectImages({
            name: 'data[front]'
        });

        $('#my-form').formPost();

    });
</script>
